﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;

namespace XW
{
    /// <summary>
    /// 项目信息变更管理类
    /// </summary>
    internal class ProjInfoChangeMgr
    {
        public ProjInfoChangeMgr() 
        {
            //注册实例
        }

        public void DoChangeProjInfo()
        {
            //获取实例
            var test = new TestChange();

            if (!test.IsDoProjInfoChange())
            {
                //日志记录
            }

            var changeFilter = new ProjChangeFilter()
            {
                ProjChangeId = Guid.NewGuid().ToString()
            };

            //获取变更信息；
            var changeInfo = test.GetProjChanges(changeFilter);

            foreach (var change in changeInfo.ChangeList)
            {
                TransactionOptions opt = new TransactionOptions();
                opt.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
                using (TransactionScope tr = new TransactionScope(TransactionScopeOption.RequiresNew, opt))
                {
                    //查询当前数据

                    //比较更改前后值

                    //记录结果状态和描述
                    var changeResult = new ProjChangeResult();
                    test.SavedEvent(changeResult);

                }
            }

        }
    }


    public class TestChange : IProjInfoChange
    {
        public ProjChangeInfo GetProjChanges(ProjChangeFilter projChangeFilter)
        {
            throw new NotImplementedException();
        }

        public bool IsDoProjInfoChange()
        {
            throw new NotImplementedException();
        }

        public void SavedEvent(ProjChangeResult projChangeResult)
        {
            throw new NotImplementedException();
        }
    }
}
